package com.aaa.controller;

import com.aaa.entity.Book;
import com.aaa.service.BookService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("book")
public class BookController {
    @Autowired
    BookService bs;

    @RequestMapping("findBook")
    public PageInfo findBook(String dynName, String docName,
                             String grand, String bookName,
                             String introduce, String memo,
                             int page, int size){
        return bs.findBook(dynName, docName, grand, bookName,
                introduce, memo,page,size);
    }
    @RequestMapping("updateBook")
    public int updateBook(Book book){
        return bs.updateBook(book);
    }

    @RequestMapping("findBookById")
    public Map findBookById(int bookId){
        System.out.println(bookId);
        return bs.findBookById(bookId);
    }

    @RequestMapping("bookAdd")
    public int bookAdd(Book book){
        return bs.bookAdd(book);
    }

    @RequestMapping("findBookDesc")
    public List<Map> findBookDesc(){
        return bs.findBookDesc();
    }
    @RequestMapping("bookDel")
    public int bookDel(int bookId){
        return bs.bookDel(bookId);
    }

    @RequestMapping("checkBook")
    public List<Map> checkBook(String bookName){
        return bs.checkBook(bookName);
    }
    @RequestMapping("findBookRepeat")
    public PageInfo findBookRepeat(int page , int size){
        return bs.findBookRepeat(page,size);
    }
}
